package com.xiguaji.tiktok.v1.ins.blogger.service;

import com.xiguaji.boot.toolkit.elasticsearch.RestClientHelper;
import com.xiguaji.tiktok.utils.ESUtil;
import com.xiguaji.tiktok.v1.ins.blogger.dto.es.InsBlogger;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * insBloggerEs相关
 * @author Huang xin
 */
@Service
public class InsBloggerEsService {

    /**
     * 从es中获取insBlogger数据
     * @param uid
     * @return
     */
    public InsBlogger getInsBloggerFromEsByUid(long uid){
        // 从es中查询数据
        List<InsBlogger> insBloggers = RestClientHelper.find(InsBlogger.class, ESUtil.INS_BLOGGER_INDEX,QueryBuilders.matchQuery("uid",uid));
        if(insBloggers != null && !insBloggers.isEmpty()){
            return insBloggers.get(0);
        }
        return null;
    }
}
